/* SRE-FILTER procedure (5/96) to access a "SWISH" index file.
Requires that a SWISH index have been previously built
using SWISH.EXE (available from:
ftp://ftp.eit.com/pub/web.software/swish/
(uses some code from DOSEARC.CMD by 3/20/1996, Kevin Vigor)
In addition, will attempt to make a short description (if desired),
using either a name= (or http-equiv=) "description" header element,
or the first several ... elements.
Options:
keyword: List of words to search for, with OR AND NOT as logical
controls (and is assumed). Note, there is NO phrase support!
index: Index file to search for (typically provided as type=hidden)
option1..option9: list of options.
Valid ones include
-t HBethc
-m #lines
header: H1 header to use (default used if none provided )
comment1..commentx: Comments to place (using ) under header
conditon: (=YES,AND,NOT) Or,and,not substituted between keywords.
Default is "and" searches.
(no substitution occurs if NOT, OR or AND is between words in keyword list)
This will not work well with (phrases) or in combination with
complex user specified search strings.
summary = NO YES CREATE
no = no summary, but check for existence
yes = look for name="description" (or http-equiv=.)
and use the "contents= field)
create = If no name=found, then use the first several
'
call lineout tempfile, "Index search results /title>"
call lineout tempfile, ""
/* Begin the result body.*/
tempdir=strip(translate(tempdir,'\','/'),'t','\')
TEMPOUT = dostempName(TEMPDIR'\ST$?????.OUT')
if tempout = "0" | tempfile="" then do
call lineout tempfile," ERROR: Could not access working directory "
call lineout tempfile," "
return 'FILE ERASE TYPE text/html NAME' tempfile
end
keywords='help'
index_file="INDEX.SWI"
swopts=' '
aheader="Search the site-index "
ncmt=0 ; door=0
summary=1
do until list=""
parse var list v1 '&' list
parse var v1 avar '=' aval ; avar=translate(avar)
if abbrev(avar,"KEYWORD")=1 then do
keywords=packur(translate(aval,' ','+'))
end
if abbrev(avar,'HEADER')=1 then do
aheader=packur(translate(aval,' ','+'))
end
if abbrev(avar,'INDEX')=1 then do
indxfile=aval
end
if abbrev(avar,'COMMENT')=1 then do
ncmt=ncmt+1
comments.ncmt=translate(aval, ' ','+'||'00090d0a'x)
end
if abbrev(avar,'COND')=1 then do
select
when abbrev(translate(aval),'Y')=1 then
door=' OR '
when abbrev(translate(aval),'O')=1 then
door=' OR '
when abbrev(translate(aval),'N')=1 then
door=' NOT '
otherwise
door=0
end
end
if abbrev(avar,'SUMMARY')=1 then do
tt=translate(aval)
summary=0
if tt="NO" then
summary=1
if tt="YES" then
summary=2
if tt="CREATE" then
summary=3
end
if abbrev(avar,'OPTION')=1 then do
swopts=swopts||" "||translate(aval,' ','+')
end
end
call lineout tempfile,' ' aheader '
'
do mm=1 to ncmt
call lineout tempfile,' ' comments.mm '
'
end
twords=translate(keywords) ; srchwords=""
/* remove silly srchwords */
do mm=1 to words(twords)
aword=word(twords,mm)
if wordpos(aword,'AND NOT OR')>0 then iterate
srchwords=srchwords||" "||aword
end
if door<>0 & words(keywords)>1 then do /* insert not / or into keyword list */
tmp=word(keywords,1) ; wasand=0
do mmm=2 to words(keywords)
aww=word(keywords,mmm) ; taw=strip(translate(aww))
if wasand=1 then do
tmp=tmp||' '||aww
wasand=0
iterate
end
if taw="OR"| taw="AND" | taw="NOT"then do
tmp=tmp||' '||aww
wasand=1
iterate
end
tmp=tmp||door||aww
end
keywords=tmp
end
t1='swish -f '||INDXfile ||' -w '||keywords||' '||swopts||' > '||tempout
foodir=directory(servdir)
address cmd
t1
address
foodir=directory(foodir)
/* get results */
gotem=fileread(tempout,'filelines',,'e')
goo=sysfiledelete(tempout)
foo=filelines.gotem
/* --- sample to test remote url retrieval
filelines.gotem='100 http://www.yahoo.com "THis is yahoo " 1 '
gotem=gotem+1
filelines.gotem=foo
---------- */
if gotem=0 then do
call lineout tempfile," ERROR: Problem searching index "
call lineout tempfile,"